package cardholder;

import java.util.ArrayList;
import java.util.List;

import applicationdeliverychannel.OnlineDeliveryChannel;

import smartcard.SmartCard;


public class CompanyCardholder implements AbstractHolderServer
{
	private String name;
	private OnlineDeliveryChannel deliveryChannel;
	private List<SmartCard> cards = new ArrayList<SmartCard>();
	
	public CompanyCardholder(String name, OnlineDeliveryChannel deliveryChannel)
	{
		this.name = name;
		this.deliveryChannel = deliveryChannel;
	}
	
	public void addCard(SmartCard card)
	{
		cards.add(card);
	}
	
	@Override
	public void sendEmail(String message)
	{
		System.out.println("CompanyCardholder: Hi " + name + ", you have new e-mail");
		System.out.println("    Message is: " + message);
	}

	public SmartCard findCard(String cardNumber)
	{
		for (SmartCard card : cards)
			if (card.getCardNumber().equals(cardNumber))
				return card;
		return null;
	}

	/* (non-Javadoc)
	 * @see cardholder.AbstractServer#getDeliveryChannel()
	 */
	@Override
	public OnlineDeliveryChannel getDeliveryChannel()
	{
		return deliveryChannel;
	}
}
